'''
    pipline缓冲多条命令，然后一次性执行，减少服务器-客户端之间TCP数据库包，从而提高效率
'''

import redis

try:
    myredis = redis.StrictRedis(host='localhost', port=6379)
except Exception as e:
    print(e.message)

pipe = myredis.pipeline()
pipe.set('name', 'xiaoming')
pipe.get('name')
resultList = pipe.execute()         # 返回一个列表, 存着上面2个命令的返回值
print(result)